
/**
 * @Date 2020/04/18
 * @author 王光浩
 * @Thinking 使用递归，肯定有DP，等会在想
 */
public class numWay {
	public int numWays(int n, int[][] relation, int k) {
		return helper(n,0,relation,k);
    }
	private int helper(int n,int index,int[][] relation,int k) {
    	if( k==0 ) {
    		if( index==n-1 )return 1;
    		return 0;
    	}
		int sum = 0;
		for(int i=0 ; i<relation.length ; i++) {
			if( relation[i][0]==index ) {
				sum += helper(n,relation[i][1],relation,k-1);
			}
		}
		return sum;
	}
}
